<?php if (!defined('THINK_PATH')) exit(); /*a:3:{s:52:"D:\Code\lvyou/application/admin\view\look\index.html";i:1534229489;s:55:"D:\Code\lvyou\application\admin\view\public\header.html";i:1534833010;s:55:"D:\Code\lvyou\application\admin\view\public\footer.html";i:1532913947;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo config('WEB_SITE_TITLE'); ?></title>
    <link href="/static/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/static/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/static/admin/css/animate.min.css" rel="stylesheet">
    <link href="/static/admin/css/style.min.css?v=4.1.0" rel="stylesheet">
    <link href="/static/admin/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="/static/layui/css/layui.css" rel="stylesheet">
    <link href="/static/admin/css/admin.css" rel="stylesheet">
    <script src="/static/admin/js/jquery.min.js?v=2.1.4"></script>
    <style type="text/css">
        .long-tr th {
            text-align: center
        }

        .long-td td {
            text-align: center
        }
    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>见闻列表</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->
            <form class="layui-form" action="" method="post">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label style="width: 95px;" class="layui-form-label">用户昵称</label>
                        <div class="layui-input-inline">
                            <input type="text" name="name" lay-verify="" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">地址</label>
                        <div class="layui-input-inline">
                            <input type="text" name="address" id="date" lay-verify="" autocomplete="off"
                                   class="layui-input" lay-key="1">
                        </div>
                    </div>
                    <button type="submit" class="btn btn-primary" lay-submit lay-filter="search">
                        <i class="fa fa-search"></i> 搜索
                    </button>

                </div>
            </form>
            <!--搜索框结束-->
            <div class="example-wrap">
                <div class="example">
                    <table lay-filter="demo">
                        <thead>
                        <tr>
                            <th lay-data="{field:'id', width:100}">id</th>
                            <th lay-data="{field:'name', width:150, sort:true}">用户名</th>
                            <th lay-data="{field:'nickname'}">发布时间</th>
                            <th lay-data="{field:'sex'}">目的地</th>
                            <th lay-data="{field:'action'}">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php if($look): foreach($look as $v): ?>
                        <tr>
                            <td><?php echo $v['id']; ?></td>
                            <td><?php echo $v['name']; ?></td>
                            <td><?php echo $v['create_time']; ?></td>
                            <td><?php echo $v['country']; ?>/<?php echo $v['province']; ?>/<?php echo $v['city']; ?>/<?php echo $v['spot']; ?></td>

                            <td>
                                <button data-id="<?php echo $v['id']; ?>" class="layui-btn layui-btn-xs member-show">查看详情</button>
                                <!--<button data-id="<?php echo $v['id']; ?>" class="layui-btn layui-btn-xs edit">编辑</button>-->
                                <button data-id="<?php echo $v['id']; ?>" class="layui-btn layui-btn-xs member-del">删除</button>
                            </td>
                        </tr>
                        <?php endforeach; endif; ?>
                        </tbody>
                    </table>
                    <?php if(($look)): ?>
                    <?php echo $look->render(); endif; ?>

                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>
<div style="display: none" id="show">
    <div class="layui-form-item">
        <label class="layui-form">用户名：</label>
        <label class="layui-form name"></label>
    </div>
    <div class="layui-form-item">
        <label class="layui-form">发布时间：</label>
        <label class="layui-form create_time"></label>
    </div>
    <div class="layui-form-item">
        <label class="layui-form">目的地：</label>
        <label class="layui-form address"></label>
    </div>
    <div class="layui-form-item">
        <label class="layui-form">感想：</label>
        <label class="layui-form feel"></label>
    </div>
    <div class="layui-form-item">
        <label class="layui-form">封面图：</label>
        <img class="src" src="">
    </div>
    <div class="layui-form-item">
        <label class="layui-form">审核状态：</label>
        <label class="layui-form state"></label>
    </div>
</div>
<script src="/static/admin/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/static/admin/js/lunhui.js"></script>
<script src="/static/layui/layui.all.js"></script>

<script>
    var table = layui.table;
    //转换静态表格
    table.init('demo', {
        height: 315 //设置高度
        ,limit: 10 //注意：请务必确保 limit 参数（默认：10）是与你服务端限定的数据条数一致
        //支持所有基础参数
    });
    //删除
    $('.member-del').click(function () {
        //获取用户id
        var obj = $(this);
        var id = $(this).attr('data-id');
        layer.confirm('是否确认删除该用户？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post('/admin/look/del',{id:id},function (data) {
                console.log(data);
                if(data.code==200){
                    layer.msg('已删除', {icon: 1});
                    $(obj).parent().parent().parent().remove();
                }else {
                    layer.msg(data.msg, {icon: 2});
                }
            },'json');

        }, function(){

        });
    });
    //查看详情
    $('.member-show').click(function () {
        var id = $(this).attr('data-id');
        //获取用户的资料
        $.post('/admin/look/get_look',{id:id},function (data) {
            console.log(data);
            if(data.code == 200) {
                $('.name').html(data.data.name);
                $('.create_time').html(data.data.create_time);
                $('.address').html(data.data.country+'/'+data.data.province+'/'+data.data.city+'/'+data.data.spot);
                $('.feel').html(data.data.feel);
                $('.src').attr('src','\\'+data.data.src);
                $('.state').html(data.data.state);
                show_tpl();
            }else {
                layer.msg(data.msg, {icon: 2});
            }


        },'json');

    });
    //查看详情弹出层
    function show_tpl() {
        layer.open({
            type: 1,
            title:'用户详情',
            closeBtn: false,
            btn: ['关闭'],
            skin: 'layui-layer-rim', //加上边框
            area: ['420px', '420px'], //宽高
            content: $('#show'),
            end: function () {
                $('#show').css('display','none');
            }
        });
    }
</script>


</body>
</html>